home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d919.lha
/
TxtCvt
/
gettype.c
next >
Wrap
C/C++ Source or Header
|
1993-10-04
|
2KB
|
89 lines
#include "txtcvt.h"
/*******************************
Check for type of inputfile
********************************/
int getfiletype(FILE *ifp)
{
int filetype = NULL;
int r;
int c;
c = fgetc(ifp);
if(c != EOF) {
switch (c) {
case 0x31 : {
c = fgetc(ifp);
if(c == 0xbe) {
r = fseek(ifp, 96, SEEK_SET);
if(r != -1) {
c = fgetc(ifp);
if(c != EOF) {
if(c == 0) {
c = fgetc(ifp);
if(c == 0) {
printf("Word 5.5\n");
filetype = DOSWORD;
}
else {
printf("Windows Write 3.1\n");
filetype = WINWRITE;
}
}
else {
printf("Windows Write 3.1\n");
filetype = WINWRITE;
}
}
}
}
}
case 0x5b : {
c = fgetc(ifp);
if(c == 0x76) {
c = fgetc(ifp);
if(c == 0x65) {
c = fgetc(ifp);
if(c == 0x72) {
c = fgetc(ifp);
if(c == 0x5d) {
printf("Ami Pro\n");
filetype = AMIPRO;
}
}
}
}
}
case 0x9b : {
c = fgetc(ifp);
if(c == 0xa5) {
printf("WinWord 1.x\n");
filetype = WINWORD1;
}
}
case 0xdb : {
c = fgetc(ifp);
if(c == 0xa5) {
printf("WinWord 2.0\n");
filetype = WINWORD2;
}
}
case 0xff : {
c = fgetc(ifp);
if(c == 0x57) {
c = fgetc(ifp);
if(c == 0x50) {
c = fgetc(ifp);
if(c == 0x43) {
printf("WordPerfect 5.x\n");
filetype = WORDPERFECT5;
}
}
}
}
}
}
return(filetype);
}